<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>套餐复制</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css" />
<script type="text/javascript" src="${layerPath}/jquery/jquery-1.8.3.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>
<script type="text/javascript"
	src="${bootstrapPath}/js/bootstrap3-validation.js"></script>
</head>
<style>
.labelShow {
	float: left;
	width: 20%;
	line-height: 30px;
	text-align: right;
}

.inputDiv {
	float: left;
	width: 50%;
}

.main {
	position: relative;
	margin: 0 auto;
	padding: 10px 10px;
	width: 570px;
	height: 350px;
}
</style>

<script type="text/javascript">
	$(function() {
		$("#copyMealForm").validation({
			icon : true
		});
		$("#exitBtn")
				.click(
						function() {
							var id = $("#id").val();
							var qName = $("#qName").val();
							var qCode = $("#qCode").val();
							var qStatus = $("#qStatus").val();
							var pager = $("#pager").val();
							parent.location.href = '${webcontext}/crmdp/dealer/meal/toEditMealPage?id='
									+ id
									+ "&qName="
									+ qName
									+ "&qCode="
									+ qCode
									+ "&qStatus="
									+ qStatus
									+ "&pager.currentPage=" + pager;
						});

		$("#saveBtn")
				.click(
						function() {
							if ($("#copyMealForm").valid(this) == false) {
								return false;
							}
							$
									.ajax({
										url : '${webcontext}/crmdp/dealer/meal/copyMealInfo',
										type : 'post',
										data : {
											'id' : $("#id").val(),
											'code' : $("#code").val(),
											'name' : $("#name").val()
										},
										success : function(data) {
											if (data.code == true) {
												jAlert(
														data.msg,
														"提示",
														function() {
															var packageDefId = data.id;
															var qName = $(
																	"#qName")
																	.val();
															var qCode = $(
																	"#qCode")
																	.val();
															var qStatus = $(
																	"#qStatus")
																	.val();
															var pager = $(
																	"#pager")
																	.val();
															parent.location.href = '${webcontext}/crmdp/dealer/meal/toEditMealPage?id='
																	+ packageDefId
																	+ "&qName="
																	+ qName
																	+ "&qCode="
																	+ qCode
																	+ "&qStatus="
																	+ qStatus
																	+ "&pager.currentPage="
																	+ pager;
														});
											} else if (data.code == false) {
												jAlert(data.msg, "提示");
											}
										},
										error : function() {
											jAlert("服务器错误，请联系管理员", "提示");
										},
									});
						});
	});
</script>
<body>
	<div class="main">
		<form:form class="form-horizontal" id="copyMealForm" method="post"
			action="" modelAttribute="dto" role="form">
			<input type="text" id="id" value="${dto.id}" class="hidden" />
			<input type="text" class="hidden" name="qName" id="qName"
				value="${qName}">
			<input type="text" class="hidden" name="qCode" id="qCode"
				value="${qCode}">
			<input type="text" class="hidden" name="qStatus" id="qStatus"
				value="${qStatus}">
			<input type="text" class="hidden" id="pager" name="pager.currentPage"
				value="${currentPage}">
			<div class="form-group">
				<label for="code" class="col-sm-2 control-label labelShow">套餐编号</label>
				<div class="col-sm-5 inputDiv">
					<input type="text" class="form-control" id="code"
						check-type="required" required-message="请填写套餐编号" />
				</div>
			</div>
			<div class="form-group">
				<label for="name" class="col-sm-2 control-label labelShow">套餐名称</label>
				<div class="col-sm-5 inputDiv">
					<input type="text" class="form-control" id="name"
						check-type="required" required-message="请填写套餐名称">
				</div>
			</div>
			<div class="form-group text-center" style="margin-left: -100px;">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="btn btn-success" id="saveBtn">保存</button>
					<button type="button" class="btn btn-success" id="exitBtn">取消</button>
				</div>
			</div>
		</form:form>
	</div>
</body>
</html>